<?php

class BeginController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column2';

	/**
	 * @return array action filters
	 */
	

public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			);
	}
	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			/*array('allow',  
				'actions'=>array('index','view','assign'),
				'users'=>array('*'),
				),*/
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('begin'),
			    'users'=>array('@'),
				),
			array('allow',
				'actions'=>array('reportes', 'reportes2'),
				'users'=>array('@'),
				),
			array('deny',  // deny all users
				'users'=>array('*'),
				),
			);
	}

	
   
    public function actionbegin()
	{
		$dataProvider=new CActiveDataProvider('usuarios');
		$this->render('begin',array(
			'dataProvider'=>$dataProvider,
			));
	}

	public function actionReportes()
	{
		$model = new reportes;

		if(isset($_POST['reportes']))
		{
			$model->attributes=$_POST['reportes'];
			
			if($model->validate())
			{
				$model->Generarreporte();
				// $model->Verificar();
				// Yii::app()->user->setFlash('success', '<strong> Se ha  agregado el producto correctamente.</strong>');//muestra el mensaje de accion
				// $this->redirect(array('create'));
			}
		}

		$this->render('reportes',array('model'=>$model,));
	}


		public function actionReportes2()
				{
					$model = new reportes;

					if(isset($_POST['reportes']))
					{
						$model->attributes=$_POST['reportes'];
						
						if($model->validate())
						{
							$model->Generarreporte2();
							// $model->Verificar();
							// Yii::app()->user->setFlash('success', '<strong> Se ha  agregado el producto correctamente.</strong>');//muestra el mensaje de accion
							// $this->redirect(array('create'));
						}
					}

					$this->render('reportes2',array('model'=>$model,));
				}


	/**
	 * Manages all models.
	 */
	
	public function loadModel($id)
	{
		$model=begin::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'No posee privilegios para acceder a esta página.');
		return $model;
	}

}
